package com.itheima.config;

import com.example.TokenParser;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import sun.misc.BASE64Encoder;

@Configuration //配置类注解
public class CommonConfig {

    //可以使用Bean注解，引入Bean到IOC容器
    @Bean
    //@ConditionalOnClass(name = "io.jsonwebtoken.Jwts") //判断Jwts类型是否存在，存在才能把base64Encoder注册容器中
    //@ConditionalOnMissingBean(name = "empController")//只有不存在某个bean，才会将当前bean注册到容器中
    @ConditionalOnProperty(name = "flag",havingValue = "true")//只有配置文件中存在flag属性，并且值为true才能将bean加入到IOC容器中
    public BASE64Encoder base64Encoder() {
        return new BASE64Encoder();
    }



}
